<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        h1 {
            color: red;
            font-size: 100px;
            text-align: center;
            margin-top: 20px;
        }

        .one {
            height: 500px;
            width: 800px;
            margin: auto;
        }

        img {
            height: 500px;
            width: 800px;
        }
    </style>
</head>

<body>
    <button class="th" id="start">开始</button>
    <button id="end">结束</button>
    <div class="one">
        <h1 id="txt">开始抽奖吧</h1>
    </div>
    <script>
        var start = document.getElementById('start')
        var end = document.getElementById('end')
        var txt = document.getElementById('txt');
        var timer;
        var list = ['<img src="images/1.jpg" alt="">', '<img src="images/4.png" alt="">', '<img src="images/2.jpg" alt="">', '<img src="images/3.jpg" alt="">', '<img src="images/5.png" alt="">'];
        console.log(list[0]);
        console.log(list.length)
        start.onclick = function () {
            clearInterval(timer)
            timer = setInterval(function () {
                var n = parseInt(Math.random() * list.length);
                txt.innerHTML = list[n];
            }, 100)
        }
        end.onclick = function () {
            clearInterval(timer);
        }
    </script>
</body>

</html>